package com.youi.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youi.common.Common;
import com.youi.common.DelStatus;
import com.youi.dao.LeaderfanDao;
import com.youi.entity.Leaderfan;
import com.youi.entity.User;
import com.youi.entity.Userwechat;
import com.youi.service.LeaderfanService;
import com.youi.service.UserService;
import com.youi.service.UserwechatService;

@Service
public class LeaderfanServiceImpl extends BaseServiceImpl<Leaderfan> implements LeaderfanService{
		
		private LeaderfanDao leaderfanDao;
		@Autowired
		private UserService userService; 
		@Autowired
		private UserwechatService userwechatService;
		@Autowired
		public void setfaultRecordDao(LeaderfanDao leaderfanDao){
			this.leaderfanDao=leaderfanDao;
			super.setBaseDAO(leaderfanDao);
		}

		@Override
		public void getLeaderfanMsg(List<Leaderfan> leaderfanList) {
			// TODO Auto-generated method stub
			if (leaderfanList!=null&&leaderfanList.size()>0) {
				for (Leaderfan leaderfan : leaderfanList) {
					Map<String, Object> params=new HashMap<String, Object>();
					params.put(Common.DELSTATUS, DelStatus.NODEL);
					params.put(Common.UNIONID, leaderfan.getUnionid());
					Userwechat userwechat=userwechatService.getByParam(params);
					if (userwechat!=null) {
						User user=userService.get(userwechat.getUserId());
						if (user!=null) {
							leaderfan.setNickname(user.getNickName());
							leaderfan.setImg(user.getImg());
						}
					}
				}
			}
		}
}